package com.cjm.one.coupon.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.constant.SecurityConstants;
import com.cjm.one.common.constant.ServerConstants;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.coupon.dto.CouponInfoDto;
import com.cjm.one.model.coupon.dto.OrderCalculateDTO;
import com.cjm.one.model.coupon.entity.CouponInfo;
import com.cjm.one.model.coupon.vo.CouponInfoVo;
import com.cjm.one.model.coupon.vo.GoodsDiscountVO;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = ServerConstants.SERVER_ONE_GOODS)
public interface CouponInfoClient {

    @GetMapping("/admin/coupon/info/list")
    @Operation(summary = "优惠券列表")
     Result<Page<CouponInfo>> list(@RequestParam(name = "current",defaultValue = "1") Long current,
                                         @RequestParam(name = "size",defaultValue = "10") Long size,
                                   @RequestParam(name = "rangeType",required = false) Integer rangeType,
                                   @RequestParam(name = "couponName",required = false) String couponName,
                                   @RequestParam(name = "status",required = false) Integer status);
    @PostMapping("/admin/coupon/info")
    @Operation(summary = "添加优惠券")
    Result<Boolean> add(@RequestBody CouponInfoDto couponInfoDto);

    @PutMapping("/admin/coupon/info")
    @Operation(summary = "修改优惠券")
    Result<Boolean> update(@RequestBody CouponInfoDto couponInfoDto);
    @DeleteMapping("/admin/coupon/info/{id}")
    @Operation(summary = "删除优惠券")
    Result<Boolean> delete(@PathVariable Long id);

    @GetMapping("/admin/coupon/info/{id}")
    @Operation(summary = "获取优惠券详情")
    Result<CouponInfoVo> get(@PathVariable Long id);


    @GetMapping("/app/coupon/info/list")
    @Operation(summary = "查询所有优惠券信息列表并判断是否被当前用户领取过")
    Result<Page<CouponInfoVo>> getList(@RequestParam Long current,
                                              @RequestParam Long size ,
                                       @RequestParam(name = "rangeType", required = false) Integer rangeType);
    @PostMapping("/app/coupon/info/calculate")
    @Operation(summary = "计算最优折扣")
    Result<List<GoodsDiscountVO>> calculateBestDiscount(
            @RequestBody OrderCalculateDTO calculateDTO,@RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource );
}
